package org.example.cicdi.service.impl.second;


import org.example.cicdi.enums.EnumWhiteColumnAnnotation;
import org.example.codegenerate.modelext.WebVo.domian.column.ColumnVoDomain;
import org.example.codegenerate.modelext.WebVo.domian.column.PageVo;
import org.example.codegenerate.modelext.WebVo.domian.table.WebModelVo;
import org.springframework.stereotype.Service;

import java.lang.reflect.Field;
import java.util.List;

@Service
public class PageVoAnnotatonImpleServiceSecond implements FieldAnnotationServiceSecond {

	@Override
	public String getCode() {
		return EnumWhiteColumnAnnotation.PageVo.getCode();
	}

	/*@Override
	public ColumnVoDomain handleFieldVo(Field field, ColumnVoDomain column, TableVoDomain tableVoDomain, List<WebModelVo> webModelVoList) {
		org.jeecg.modules.codegenerate.modelext.WebVo.annotation.Column.PageVo vo = field.getAnnotation(org.jeecg.modules.codegenerate.modelext.WebVo.annotation.Column.PageVo.class);
		if (vo != null) {
			PageVo page = column.getPageVo();
			//org.jeecg.modules.codegenerate.modelext.WebVo.domian.column
			if (page == null) {
				page = new PageVo();
				column.setPageVo(page);
			}
			
			page.setFieldDefaultValue(vo.fieldDefaultValue());
			page.setFieldLength(vo.fieldLength());
			//page.setFieldShowType(vo.fieldShowType());
			page.setFieldShowType(vo.fieldShowType().getType());

			page.setIsQuery(vo.isQuery());
			page.setIsReadOnly(vo.isReadOnly());
			page.setIsShowForm(vo.isShowForm());
			page.setIsShowList(vo.isShowList());
			page.setOrderNum(vo.orderNum());
			page.setQueryMode(vo.queryMode());
			page.setSortFlag(vo.sortFlag());
			page.setOrderNum(vo.orderNum());
			column.setPageVo(page);
		}

		return column;
	}*/
	//这个方法中传入了WebModelVo，及WebModelVoList没有作用
	public ColumnVoDomain handleFieldVo(Field field, ColumnVoDomain column, WebModelVo webModelVo, List<WebModelVo> webModelVoList){
		org.example.codegenerate.modelext.WebVo.annotation.Column.PageVo vo = field.getAnnotation(org.example.codegenerate.modelext.WebVo.annotation.Column.PageVo.class);
		if (vo != null) {
			PageVo page = column.getPageVo();
			//org.jeecg.modules.codegenerate.modelext.WebVo.domian.column
			if (page == null) {
				page = new PageVo();
				column.setPageVo(page);
			}

			page.setFieldDefaultValue(vo.fieldDefaultValue());
			page.setFieldLength(vo.fieldLength());
			//page.setFieldShowType(vo.fieldShowType());
			page.setFieldShowType(vo.fieldShowType().getType());

			page.setIsQuery(vo.isQuery());
			page.setIsReadOnly(vo.isReadOnly());
			page.setIsShowForm(vo.isShowForm());
			page.setIsShowList(vo.isShowList());
			page.setOrderNum(vo.orderNum());
			page.setQueryMode(vo.queryMode());
			page.setSortFlag(vo.sortFlag());
			page.setOrderNum(vo.orderNum());
			column.setPageVo(page);
		}

		return column;
	}
}
